/**
 * 主页接口
 */
import request from "@/utils/request";
import primordialRequest from "@/utils/primordialRequest";
import env from "@/utils/env";
import { getItem, setItem } from "@/utils/localStorage";

// 轮播图
export const swiperList = (pageNo = 1, pageSize = 10) => {
  return request({
    method: "GET",
    url: `/studio/banner?pageNo=${pageNo}&pageSize=${pageSize}`,
  });
};

// 简历列表
// export const resumeList = (pageNo, limit, type = 0) => {
//   return request({
//     method: "GET",
//     // url: `/front/user/recommend?page=${pageNo}&size=${limit}`,
//     url: `/front/user/recommend/${type}?page=${pageNo}&size=${limit}&sort=created_time&order=desc`,
//   });
// };

export const resumeList = (pageNo, limit, type = "") => {
  // 格式化处理欢乐写的的不规范接口
  const typeFormat = type == "" ? "" : `/${type}`;

  return request({
    method: "GET",
    url: `/studio/user/home${typeFormat}?pageNo=${pageNo}&pageSize=${limit}`,
  });
};

// 点开感兴趣
export const interest = (likeId) => {
  return request({
    method: "GET",
    // url: `/front/user/query?ownId=${getItem("userInfo").id}&likeId=${likeId}`, // ownId：本人id,   likeId：感兴趣的id
    url: `/studio/user/interest/${getItem("userInfo").id}/${likeId}`,
  });
};

// 点击喜欢
export const likeApi = (id) => {
  return request({
    method: "GET",
    // url: `/front/user/like/YoN?ownId=${
    //   getItem("userInfo").id
    // }&likeId=${id}&isChoose=${Number(status)}`,
    url: `/studio/user-like/YoN/${getItem("userInfo").id}/${Number(id)}`,
  });
};

// 点击收藏
export const collectApi = (id) => {
  return request({
    method: "GET",
    // url: `/front/user/collect/YoN?ownId=${
    //   getItem("userInfo").id
    // }&likeId=${id}&isChoose=${Number(status)}`,
    url: `/studio/user-col/YoN/${getItem("userInfo").id}/${Number(id)}`,
  });
};

// 查询用户IP
// export const getIp = () => {
//   return primordialRequest({
//     method: "GET",
//     url: "https://2024.ipchaxun.com/",
//   });
// };
export const getIp = () => {
  return primordialRequest({
    method: "GET",
    url: "https://api.vvhan.com/api/ipInfo",
  });
};

// 更新用户IP
export const updateIp = (data) => {
  return request({
    method: "POST",
    url: "/front/user/getDetail",
    data,
  });
};

// 由于当前小程序属于个人小程序，有些内容需要企业资格才可以审核通过展示，
// 所以需要给腾讯审核员一个假行为，审核期间让其相应内容隐藏，审核通过后发布前给予显示
export const checkShow = () => {
  return request({
    method: "GET",
    url: "/studio/check",
  });
};
